package com.auxgroup.smarthome.inner.repo;

import com.auxgroup.smarthome.inner.entity.DeviceSnModelMappingEntity;
import com.auxgroup.smarthome.repo.GenericDao;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by niuGuangzhe on 2017/7/29.
 */
public interface DeviceSnModelMappingEntityRepo extends GenericDao<DeviceSnModelMappingEntity,String> {
    //根据sn码查找设备内机描述
    DeviceSnModelMappingEntity findBySn(String sn);

    //分组根据关键字获取物料信息
    @Query(value = "select distinct o.model_item from device_sn_model_mapping o group by o.model_item having o.model_item <> '' and o.model_item like ? order by o.model_item limit ?,?",nativeQuery = true)
    List<String> findAllModeItemByKeyword(String modelRegExp,int page,int size);

    @Query(value = "select distinct o.model_item from device_sn_model_mapping o group by o.model_item having o.model_item <> '' order by o.model_item limit ?,?",nativeQuery = true)
    List<String> catchAllModelItem(int page,int size);
}
